<template>
  <div class="PaperTitle" v-loading="loading">
    <div class="box" :style="{ height: Height + 'px' }">
      <div class="text">{{ $t("reset.Welcome") }}</div>
      <div class="login">
        <div class="title">{{ $t("reset.Forgotpassword") }}</div>
        <div class="text2">{{ $t("reset.YouID") }}</div>
        <el-input
          class="int1"
          :placeholder="$t('reset.EnterYoulD')"
          v-model="query.user_code"
          clearable
        >
        </el-input>
        <div class="text3">{{ $t("reset.ReferrallD") }}</div>
        <el-input
          class="int2"
          :placeholder="$t('reset.EnterReferrallD')"
          v-model="query.user_password"
          clearable
        >
        </el-input>
        <div class="text4">{{ $t("reset.NewPasswordEnterPassword") }}</div>
        <el-input
          class="int3"
          :placeholder="$t('reset.EnterPassword')"
          v-model="query.new_password"
          clearable
        >
        </el-input>
        <div class="btn cursor" @click="submitFn">OK</div>
      </div>
    </div>
  </div>
</template>

<script>
import { forhot } from "@/api/login.js"; // 重置接口

export default {
  name: "reset",
  data() {
    return {
      Height: null,
      loading: false, // loading
      query: {
        user_code: "", // 用户账号
        user_password: "", // 推荐人id
        new_password: "", // 重置密码
      },
    };
  },
  created() {
    this.Height = sessionStorage.getItem("heights");
  },
  methods: {
    submitFn() {
      this.forhot(this.query);
    },
    // 重置接口
    async forhot(query) {
      this.loading = true;
      try {
        const data = await forhot(query);
        if (data.result_code == 200) {
          this.$message({
            type: "success",
            message: data.msg,
          });
          this.$router.push({
            path: "/login",
          });
        } else {
          this.$message({
            type: "error",
            message: data.msg,
          });
        }
        this.loading = false;
      } catch (error) {
        console.log(error);
        this.loading = false;
      }
    },
  },
};
</script>

<style  lang="scss" scoped>
@media only screen and (max-width: 768px) {
  .PaperTitle {
    font-size: 40px;
  }
}
@media only screen and (min-width: 800px) {
  .PaperTitle {
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
  }
  .box {
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    background: url("~@/assets/imgs/bg.png") no-repeat;
    background-size: 100% 100%;
  }
  .text {
    box-sizing: border-box;
    width: 512px;
    height: 127px;
    font-size: 50px;
    font-weight: bold;
    color: #ffffff;
    line-height: 80px;
    margin: 71px 0 0 232px;
  }
  .login {
    position: absolute;
    top: 71px;
    right: 232px;
    box-sizing: border-box;
    width: 768px;
    height: 725px;
    background: #ffffff;
    border-radius: 30px;
  }
  .title {
    position: absolute;
    top: 68px;
    left: 109px;
    width: 445px;
    height: 36px;
    font-size: 48px;
    font-weight: bold;
    color: #1a1a1a;
  }
  ::v-deep .el-input {
    width: 582px;
  }
  ::v-deep .el-input__inner {
    width: 582px;
    height: 78px;
    border: 1px solid #999999;
    border-radius: 20px;
    font-size: 28px;
    font-weight: 400;
    color: #999999;
    line-height: 110px;
  }
  ::v-deep .el-input__suffix {
    .el-icon-circle-close:before {
      font-size: 32px;
      line-height: 70px;
      padding-right: 100px;
    }
  }
  .text2 {
    position: absolute;
    top: 140px;
    left: 109px;
    width: 185px;
    height: 22px;
    font-size: 28px;
    font-weight: 400;
    color: #666666;
  }
  .int1 {
    position: absolute;
    top: 186px;
    left: 94px;
  }
  .text3 {
    position: absolute;
    top: 280px;
    left: 109px;
    width: 185px;
    height: 22px;
    font-size: 28px;
    font-weight: 400;
    color: #666666;
  }
  .int2 {
    position: absolute;
    top: 323px;
    left: 94px;
  }
  .text4 {
    position: absolute;
    top: 417px;
    left: 109px;
    height: 22px;
    font-size: 28px;
    font-weight: 400;
    color: #666666;
  }
  .int3 {
    position: absolute;
    top: 460px;
    left: 94px;
  }
  .btn {
    position: absolute;
    left: 95px;
    bottom: 65px;
    width: 584px;
    height: 75px;
    background: linear-gradient(90deg, #5f20d4 0%, #2e68f6 100%);
    border-radius: 20px;
    text-align: center;
    line-height: 75px;
    font-size: 30px;
    font-weight: bold;
    color: #fefefe;
  }
}
</style>